home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Scheduling / Cassandra / Source / convert / Event.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-03  |  6.1 KB  |  199 lines

  1. //
  2. // Event.h
  3. // Copyright (c) 1989, 1990 by Jiro Nakamura 
  4. // All rights reserved
  5. //
  6. // Interface definition of class Event. Event handles the database management
  7. // of Cassandra.
  8. // Event is due for total rewriting.
  9. //
  10. // RCS Information
  11. // Revision Number->    $Revision: 1.10 $
  12. // Last Revised->        $Date: 90/12/03 01:55:44 $
  13. //
  14.  
  15. #import <objc/Object.h>
  16. #import <time.h>
  17. #import "cass.h"    
  18.  
  19. struct tm *fixAnniversary( struct tm *time, int mode, int sub);
  20. @interface Event : Object
  21. {
  22.     char eventFile[128];    // The pathname of the event database
  23.  
  24.     EFileLink    present, previous, next;    // links to 
  25.                 //previous and next records and itself 
  26.                 // See documentation for queue implementation
  27.                 // details
  28.                 
  29.     struct tm ts;        // time structure  see ctime(3) for details 
  30.     int    priority,    // Priority of message (when it gets viewed) 
  31.         destroy,    // Destroy after message?     0= never destroy
  32.                 //  1 = destroy immediately after, 
  33.                 //   2...n = destroy after n calls 
  34.         snoozeNo,    // No of snooze times
  35.         snoozeInt;    // The snooze intervals themselves (in minutes) 
  36.                 
  37.     int    anniversary;    // Anniversary event, 
  38.                 // 0 = no anniversary 
  39.                 // (int) (anniversary / 100) is the "base
  40.                 // interval": 
  41.                 //  1 = daily      
  42.                 //  2 = weekly
  43.                 //  3 = monthly
  44.                 //  4 = yearly
  45.                 //  5 = special weekly - see "Annv Special Field" for
  46.                 //    days. Base interval is a binary flag field
  47.                 //    for which week it is in:  Bit 0: First week
  48.                 //                  Bit 4: Fifth week
  49.                 // anniversary % 100 is the number of 
  50.                 // "base interval" that
  51.                 // make up the "true interval" 
  52.                 // between anniversary events
  53.     
  54.     int    annvSpecial;    // Anniversary special field
  55.                 // For Special weekly it holds the days in a binary
  56.                 // flag field:
  57.                 //     Bit 0:    Sunday
  58.                 //     Bit 7: Saturday
  59.                 
  60.     BOOL playAlarm;        // Whether to play the alarm or not
  61.     BOOL showMessage;    // Whether to show the alarmPanel or not
  62.     BOOL deleteSound;    // Whether to delete the alarm sound after playing
  63.     char alarmSound[128];    /* The alarm sound name */
  64.     char msg[MESSAGE_SIZE];    /* message buffer */
  65.  
  66.     id global;        // Set by IB. Accessor to Global class
  67. }
  68. // Constructor:        newAt: (const char *) eFile;
  69. // Description:        Constructs new object instance of Event, with the Event
  70. //                reading the file <eFile>
  71. +newAt: (const char *) eFile;
  72.  
  73. /* low level routines  dealing with event links themselves */ 
  74.  
  75. // Method:        readEvent : (EFileLink) here
  76. // Arguments:        (EFileLink) here  -> the EFileLink to read from
  77. // Description:        Reads the event directly from the queue with <here> 
  78. //            as the index.
  79. // Return Value:    <self>
  80. - readEvent : (EFileLink) here;    
  81.  
  82.  
  83. // Method:        writeEvent : (EFileLink) here
  84. // Arguments:        (EFileLink) here  -> the EFileLink to write to
  85. // Description:        Writes the event directly into the queue 
  86. //            with <here> as the index. Note that this is not an 
  87. //            insert, so the next and previous pointers from the 
  88. //            last read from this event should be preserved
  89. //            or new pointers should be made and changed 
  90. //            appropriately.
  91. // Return Value:    <self>
  92. - writeEvent : (EFileLink) here;     /* write itself into the event file */
  93.  
  94.  
  95.  
  96. /* Higher level methods that deal somewhat abstractly with the queue */        
  97.  
  98. // Method:        firstEvent
  99. // Arguments:        None.
  100. // Description:        reads the first event. Equivalent to:
  101. //                [ev readEvent:0];
  102. //                [ev readEvent:  [ev next]];
  103. // Return Value:    returns with the first event read into its internals
  104. - firstEvent;            
  105.  
  106.  
  107. // Method:        (EFileLink) insertEvent
  108. // Arguments:        None, event to be inserted must be already in object
  109. // Description:        Inserts itself into the queue. It is intelligent
  110. //            enough to convert all mistaken dates and times into the
  111. //            proper format before inserting itself, so that other
  112. //            modules that use it can simply add blindly to dates.
  113. //            insertEvent is equivalent to insertEventFrom: 1
  114. // Return Value:    The particular EFileLink that it inserted itself into.
  115. - (EFileLink) insertEvent;    
  116.  
  117.  
  118. // Method:        (EFileLink) insertEventFrom: (EFileLink) here
  119. // Arguments:        (EFileLink) here   -> start inserting from <here>
  120. // Description:        Same as insertEvent except that the search
  121. //            for empty events starts from <here>, so that
  122. //            if you KNOW where an deleted EFileLink is, 
  123. //            then you can use this method to speed things up
  124. //             somewhat.
  125. // ReturnValue:        The EFileLink that it inserted itself into.
  126. - (EFileLink) insertEventFrom: (EFileLink) here;
  127.  
  128.  
  129. // Method:        deleteEvent: (EFileLink) here
  130. // Arguments:        (EFileLink) here   -> the event to delete
  131. // Description:        Delete the event <here>
  132. // Return Value:    <self>
  133. - deleteEvent : (EFileLink) here;    
  134.  
  135.  
  136. // Method:        int murderEvent : (EFileLink) here
  137. // Arguments:        (EFileLink) here   -> the event to "murder"
  138. // Description:        "Murdering" an event deletes an event, but 
  139. //            if it is an anniversary
  140. //            event, then it reinstalls it appropriately
  141. //            in the future. See above for description
  142. //            of state variables for "anniversary" events.
  143. // Return Value:    The EFileLink where the new event lies.  
  144. //            -1 if it was not reinserted
  145. - (int) murderEvent : (EFileLink) here;    
  146.  
  147. /*  Accessors */
  148. /* See heading above for description of these variables */
  149. - (EFileLink) present;    
  150. - (EFileLink) previous;
  151. - (EFileLink) next;
  152. - (int) destroy;
  153. - (int) priority;
  154. - (int) anniversary;
  155. - (int) annvSpecial;
  156. - (int) snoozeNo;
  157. - (int) snoozeInt;
  158. - (BOOL) playAlarm;
  159. - (BOOL) showMessage;
  160. - (BOOL) deleteSound;
  161. - (char *) alarmSound;
  162. - (char *) message;
  163. - (struct tm *) time;
  164. - (int) mday;        // These access the time structure directly, instead of
  165. - (int) mon;        // using the structure accessors
  166. - (int) year;
  167. - (int) hour;
  168. - (int) min;
  169. - (int) sec;
  170. - (int) wday;
  171. - (int) yday;
  172.  
  173. - setPresent : (EFileLink) apresent;
  174. - setPrevious : (EFileLink) aprevious;
  175. - setNext : (EFileLink) anext;
  176. - setDestroy : (int) dst;
  177. - setPriority : (int) si;
  178. - setAnniversary : (int) anv;
  179. - setAnnvSpecial: (int) anvS;
  180. - setSnoozeNo : (int) sn;
  181. - setSnoozeInt: (int) si;
  182. - setPlayAlarm: (BOOL) aFlag;
  183. - setShowMessage: (BOOL) aFlag;
  184. - setDeleteSound:(BOOL) aFlag;
  185. - setAlarmSound: (char *) alarmSound;
  186. - setMessage: (char *) message;
  187. - setTime : (struct tm *) time;
  188. - setMday : (int) x;
  189. - setMon: (int) x;
  190. - setYear: (int) x;
  191. - setHour: (int) x;
  192. - setMin: (int) x;
  193. - setSec: (int) x;
  194. - setWday: (int) x;
  195. - setYday:(int) x;
  196. @end
  197.  
  198.  
  199.